package com.hlkj.pay.controller.admin;
/*
 * Hlpay-Plus aggregate payment system.
 * Copyright (c) 2024-2025 Hlpay Team Copyright has the right of final interpretation.
 */

import java.util.List;

import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import com.hlkj.framework.common.pojo.CommonResult;
import com.hlkj.framework.common.pojo.PageResult;
import com.hlkj.pay.app.adminuser.IPermissionAppService;
import com.hlkj.pay.vo.admin.req.user.MenuPageQueryReq;
import com.hlkj.pay.vo.admin.resp.menu.RoleDetailMenuResp;
import com.hlkj.pay.vo.admin.resp.permission.PermissionDetailResp;
import com.hlkj.pay.vo.common.req.DeleteCodeReq;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
/**
 * @author HlpayTeam
 * @date 2024/09/18 15:58
 */
@Tag(name = "菜单配置")
@Slf4j
@RestController
@RequiredArgsConstructor
@RequestMapping("/v1/adminuser/menu")
public class PermissionController {
	private final IPermissionAppService permissionAppService;
	@Operation(summary  = "菜单列表分页")
	@GetMapping("/page")
	public CommonResult<PageResult<RoleDetailMenuResp>> queryPermissionPage(MenuPageQueryReq menuPageQueryReq) {
		return CommonResult.success(permissionAppService.queryPermissionPage(menuPageQueryReq));
	}
	@Operation(summary  = "菜单列表不分页")
	@GetMapping("")
	public CommonResult<List<RoleDetailMenuResp>> queryPermission(MenuPageQueryReq menuPageQueryReq) {
		return CommonResult.success(permissionAppService.queryPermission(menuPageQueryReq));
	}
	
	@Operation(summary  = "菜单详情")
	@GetMapping("/detail")
	public CommonResult<PermissionDetailResp> queryPermissionDetail(@RequestParam("code") String code) {
		return permissionAppService.queryPermissionDetail(code);
	}
	
	@Operation(summary  = "新增菜单")
	@PostMapping("")
	public CommonResult<String> addPermission(@Validated @RequestBody PermissionDetailResp permissionDetailReq) {
		return permissionAppService.addPermission(permissionDetailReq);
	}
	
	@Operation(summary  = "更新菜单")
	@PutMapping("")
	CommonResult<Void> updatePermission(@Validated @RequestBody PermissionDetailResp permissionDetailReq) {
		return permissionAppService.updatePermission(permissionDetailReq);
	}
	
	@Operation(summary  = "删除菜单")
	@DeleteMapping("")
	CommonResult<Void> deletePermission(@Validated @RequestBody DeleteCodeReq deleteCodeReq) {
		return permissionAppService.deletePermission(deleteCodeReq.getCode());
	}
	
}
